1. Field of the Invention
The present invention relates to disk drives for computer systems. More particularly, the present invention relates to a disk drive for dynamically allocating memory accessed concurrently by a host interface and a disk interface to facilitate large host commands.
2. Description of the Prior Art
Disk drives process commands received from a host to write data to and read data from a disk. A volatile semiconductor memory may be employed to stage write-data before being written to the disk as well as stage read-data before being transferred to the host. The semiconductor memory is also used as a cache memory which enhances the drive""s operation since the cache memory is accessed much faster than the disk. The semiconductor memory is statically partitioned into a staging segment and a caching segment when the disk drive is configured during a power-on sequence. Consequently, the capacity of the staging segment is fixed leading to interruptions in host operations if the staging segment fills to capacity. The disk drive must wait until data is transferred out of the staging segment (to the disk or to the host) before the host operation can resume. This is undesirable since interrupting host operations degrades performance.
U.S. Pat. No. 6,038,619 discloses a disk drive employing a circular buffer for the staging segment which is accessed concurrently by a host interface process and a disk interface process. In this manner, the staging segment is filled and emptied concurrently during host operations which improves performance by effectively increasing the size of the staging segment. However, in the aforementioned patent the size of the circular buffer is static and may still overflow if the size of a host operation exceeds the latency of the disk and/or host interface.
There is, therefore, a need to improve the staging of data in a disk drive to help prevent interrupting a host""s access to the disk drive.
The present invention may be regarded as a disk drive comprising a disk, a head actuated radially over the disk, and a semiconductor memory comprising addressable locations for staging and caching data, wherein each addressable location having an allocation status. The disk drive further comprises a disk controller which receives a write command from a host to write write-data to the disk, wherein the write-data comprises a first segment, a second segment and a third segment. The disk controller dynamically allocates a plurality of the addressable locations relative to the size of the write command and the allocation status of the addressable locations. The first segment of write-data is received from the host and stored in the dynamically allocated addressable locations. The second segment of write-data is received from the host and stored in the dynamically allocated addressable locations while concurrently reading the first segment of write-data from the dynamically allocated addressable locations and writing the first segment of write-data to the disk. The dynamically allocated addressable locations are re-used for storing the third segment of write-data received from the host after writing the first segment of write-data to the disk.
In one embodiment, the addressable locations are also used to stage read-data to facilitate read commands. The disk controller receives a read command from the host to read read-data from the disk, wherein the read-data comprises a first segment, a second segment and a third segment. The disk controller dynamically allocates a plurality of the addressable locations relative to the size of the read command and the allocation status of the addressable locations. The first segment of read-data is read from the disk and stored in the dynamically allocated addressable locations. The second segment of read-data is read from the disk and stored in the dynamically allocated addressable locations while concurrently reading the first segment of read-data from the dynamically allocated addressable locations and transmitting the first segment of read-data to the host. The dynamically allocated addressable locations are re-used for storing the third segment of read-data read from the disk after transmitting the first segment of read-data to the host.
In one embodiment, the allocation status is assigned a value selected from the group consisting of free, available, valid, and dirty. The free allocation status indicates an addressable location is not allocated, the available allocation status indicates an addressable location stores cached write-data written to the disk and therefore available for re-allocation, the valid allocation status indicates an addressable location stores cached read-data that can be selectively re-allocated, and the dirty allocation status indicates an addressable location stores staged write-data not yet written to the disk and therefore not available for re-allocation.
In one embodiment, the disk controller dynamically allocates addressable locations having a free allocation status first, dynamically allocates addressable locations having an available allocation status second, and dynamically allocates addressable locations having a valid allocation status third.
In one embodiment, before dynamically allocating all of the addressable locations having a valid allocation status, the disk controller writes at least part of the staged write-data to the disk, changes the corresponding addressable locations from a dirty allocation status to an available allocation status, and dynamically allocates the addressable locations updated to the available allocation status.
In one embodiment, when the disk controller dynamically allocates addressable locations having a valid allocation status, the disk controller selects the addressable locations storing the least recently used cached read-data.
In one embodiment, the number of addressable locations dynamically allocated by the disk controller increases with the number of addressable locations having a free allocation status and an available allocation status.
The present invention may also be regarded as a method of processing host commands in a disk drive. The disk drive comprises a disk, a head actuated radially over the disk, and a semiconductor memory comprising addressable locations for staging and caching data, wherein each addressable location having an allocation status. A write command is received from a host to write write-data to the disk, wherein the write-data comprises a first segment, a second segment and a third segment. A plurality of the addressable locations are dynamically allocated relative to the size of the write command and the allocation status of the addressable locations. The first segment of write-data received from the host is stored in the dynamically allocated addressable locations. The second segment of write-data received from the host is stored in the dynamically allocated addressable locations while concurrently reading the first segment of write-data from the dynamically allocated addressable locations and writing the first segment of write-data to the disk. The dynamically allocated addressable locations are re-used for storing the third segment of write-data received from the host after writing the first segment of write-data to the disk.